<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/9/10
 * Time: 10:59
 */

namespace app\index\controller;

use app\index\server\OrderServer;
use app\index\validate\ConfirmToGoods;
use app\index\validate\IDMustBePostiveInt;
use app\index\validate\GetListValidate;
use app\index\validate\OrderValidate;
use think\Request;

class Order extends Auth
{
    private $server;

    public function __construct()
    {
       $this->server = new OrderServer();
    }

    public function getOrderList()
    {
        $params = ( new GetListValidate() )->goCheck();
        $result = $this->server->getOrderList($params, 1);
        return $result;
    }

    // 获取用户状态为2 的 已支付但是没有发货
    public function getStatusTwo()
    {
        $params = ( new GetListValidate() )->goCheck();
        $result = $this->server->getOrderList($params, 2);
        return $result;
    }

    // 获取用户状态为3 的 已支付 已发货
    public function getStatusThree()
    {
        $params = ( new GetListValidate() )->goCheck();
        $result = $this->server->getOrderList($params, 3);
        return $result;
    }

    // 获取用户状态为4 的 已支付 已发货
    public function getStatusFour()
    {
        $params = ( new GetListValidate() )->goCheck();
        $result = $this->server->getOrderList($params, 4);
        return $result;
    }

    // 获取用户状态为8 的 已支付 已发货
    public function getStatusEight()
    {
        $params = ( new GetListValidate() )->goCheck();
        $result = $this->server->getOrderList($params, 8);
        return $result;
    }

    // 获取用户状态为9 的 已支付 回调报错
    public function getStatusNine()
    {
        $params = ( new GetListValidate() )->goCheck();
        $result = $this->server->getOrderList($params, 9);
        return $result;
    }

    // 获得用户的订单详情信息
    public function getOrderDetail($id)
    {
        (new IDMustBePostiveInt())->goCheck();
        $result = $this->server->getInfo($id);
        if(!$result) {
            return setMsg(0, '未找到此订单信息');
        }
        return setMsg(1, 'OK', $result);
    }

    // 确认发货
    public function confirm_goods()
    {
        $params = (new ConfirmToGoods())->goCheck();
        $result = $this->server->confirm_goods($params);
        return $result;
    }

    // 确认收货
    public function collectGoods()
    {
        $params = (new IDMustBePostiveInt())->goCheck();
        $result = $this->server->collectGoods($params);
        return $result;
    }

    // 展示订单详情
    public function product_detail($id)
    {
        (new IDMustBePostiveInt())->goCheck();
        $result = $this->server->product_detail($id);
        return $result;
    }
}